﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public enum PetState
{
    walk,
    run,
    Rolling
}
/// <summary>
/// 宠物动画切换
/// </summary>
public class BullAnimation : MonoBehaviour
{
    PetState petState;
    Animator ani;
    public Animator Ani
    {
        get
        {
            if (ani == null)
            {
                ani = GameObject.Find("Bull(Clone)").GetComponent<Animator>();
            }
            return ani;
        }
        set
        {
            ani = value;
        }
    }


    /// <summary>
    /// 播放行走动画
    /// </summary>
    public void OnWalkButtonClick()
    {
        petState = PetState.walk;
        StateChange();
    }
    /// <summary>
    /// 播放跑步动画
    /// </summary>
    public void OnRunButtonCLick()
    {
        petState = PetState.run;
        StateChange();

    }
    /// <summary>
    /// 播放翻跟头动画
    /// </summary>
    public void OnRollingButtonClick()
    {
        petState = PetState.Rolling;
        StateChange();

    }

    /// <summary>
    /// 状态改变
    /// </summary>
    void StateChange()
    {
        switch (petState)
        {
            case PetState.walk:
                Ani.SetBool("isSwim", true);
                Ani.SetBool("isRun", false);
                break;
            case PetState.run:
                Ani.SetBool("isRun", true);
                Ani.SetBool("isSwim", false);
                break;
            case PetState.Rolling:
                Ani.SetBool("isRoll",true);
                Ani.SetBool("isRun", false);
                Ani.SetBool("isSwim", false);
                break;
        }
    }
}
